import { SActiveToClient } from "../../../../../Message/Public/SActiveToClient";
import { SecTimer } from "../../../../../com/gengine/core/frame/SecTimer";
import { TimerType } from "../../../../../com/gengine/core/frame/TimerType";
import { ClockManager } from "../../../manager/ClockManager";
import { OpenRechargeGiftBagConfig } from "../../../resource/OpenRechargeGiftBagConfig";
import { GiftBagConfig } from "../../../resource/GiftBagConfig";
import { ECategory } from "../../../../../Message/Public/ECategory";
import { EColor } from "../../../../../Message/Public/EColor";
import { EEquip } from "../../../../../Message/Public/EEquip";
import { EProp } from "../../../../../Message/Public/EProp";
type int = number;
//class RechargeData
    
    export  class RechargeData
    {
        

        public static set activeToClient(arg1: SActiveToClient)
        {
            var loc1=null;
            var loc2=null;
            RechargeData._activeToClient = arg1;
            if (!RechargeData._secTimer) 
            {
                RechargeData._secTimer = new SecTimer();
                RechargeData._secTimer.addListener(TimerType.ENTERFRAME, RechargeData.onTimerEnterFrameHandler);
                RechargeData._secTimer.addListener(TimerType.COMPLETE, RechargeData.onTimerCompleteHandler);
            }
            if (RechargeData._activeToClient) 
            {
                loc1 = ClockManager.instance.nowDate;
                loc2 = RechargeData._activeToClient.endDt;
                RechargeData._resTime = (loc2.time - loc1.time) / 1000;
            }
            RechargeData._secTimer.reset();
            RechargeData._secTimer.repeatCount = RechargeData._resTime;
            RechargeData._secTimer.start();
            return;
        }

        /* internal  */static onTimerEnterFrameHandler(arg1: SecTimer): void
        {
            --RechargeData._resTime;
            return;
        }

        /* internal  */static onTimerCompleteHandler(arg1: SecTimer): void
        {
            arg1.stop();
            arg1.isDelete = false;
            return;
        }

        public static get isRechargeActive(): Boolean
        {
            var loc1=false;
            if (RechargeData._activeToClient && RechargeData._resTime > 0) 
            {
                loc1 = true;
            }
            return loc1;
        }

        public static get restTime(): int
        {
            return RechargeData._resTime;
        }

        public static isHadGet(arg1: int): Boolean
        {
            var loc2=0;
            var loc1=false;
            if (RechargeData.hadGetCodes && RechargeData.hadGetCodes.length > 0) 
            {
                loc2 = 0;
                while (loc2 < RechargeData.hadGetCodes.length) 
                {
                    if (arg1 == RechargeData.hadGetCodes[loc2]) 
                    {
                        loc1 = true;
                    }
                    ++loc2;
                }
            }
            return loc1;
        }

        public static getRechargeValuables(): Array<any>
        {
            var loc5=null;
            var loc6=0;
            var loc7=0;
            var loc8=null;
            var loc1=[];
            var loc2=OpenRechargeGiftBagConfig.instance.getOpenRechargeGiftBagMap();
            var loc3=[];
            var loc4=0;
            var loc9=0;
            var loc10=loc2;
            for(loc8 of loc10) 
            {
                if (loc8.code <= 3) 
                {
                    continue;
                }
                loc3 = GiftBagConfig.instance.getInfoByType(loc8.itemCode);
                if (!loc3) 
                {
                    continue;
                }
                loc4 = 0;
                while (loc4 < loc3.length) 
                {
                    if (!(!(loc5 = loc3[loc4]) || !loc5.item)) 
                    {
                        loc6 = loc5.item.category;
                        loc7 = loc5.item.type;
                        if (loc6 == ECategory._ECategoryEquip && loc5.item.color >= EColor._EColorPurple && (loc7 == EEquip._EEquipFashion || loc7 == EEquip._EEquipWing)) 
                        {
                            loc1.push(loc5);
                            RechargeData.codeMap[loc8.code] = loc5.code;
                            RechargeData.infoMap[loc5.code] = loc8;
                        }
                        else if (loc6 != ECategory._ECategoryMount) 
                        {
                            if (loc6 == ECategory._ECategoryProp && loc7 == EProp._EPropPetEgg) 
                            {
                                loc1.push(loc5);
                                RechargeData.codeMap[loc8.code] = loc5.code;
                                RechargeData.infoMap[loc5.code] = loc8;
                            }
                        }
                        else 
                        {
                            loc1.push(loc5);
                            RechargeData.codeMap[loc8.code] = loc5.code;
                            RechargeData.infoMap[loc5.code] = loc8;
                        }
                    }
                    ++loc4;
                }
            }
            return loc1;
        }

        /* internal */ static /* var */_activeToClient: SActiveToClient;

        /* internal */ static /* var */_secTimer: SecTimer;

        /* internal */ static /* var */_resTime: int;

        public static /* var */hadGetCodes: Array<any>;

        public static /* var */codeMap: Map<any, any> /* flash.utils.Dictionary */;

        public static /* var */infoMap: Map<any, any> /* flash.utils.Dictionary */;
    }

            RechargeData.codeMap = new Map<any, any> /* flash.utils.Dictionary */();
            RechargeData.infoMap = new Map<any, any> /* flash.utils.Dictionary */();
        